<?php
namespace app\shops\controller;

use think\Controller;
use think\Session;
use think\Db;

/**
 * 自定义基层类
 */
class Base extends Controller
{
    protected $shop_id,$shop_user_name,$shop_name;

    /**
     * 构造方法
     */
    public function __construct()
    {
        parent::__construct();

        // 验证是否登陆
        Session::get('shop_id')	        == null || $this->shop_id  			= Session::get('shop_id');
        Session::get('shop_user_name')	== null || $this->shop_user_name 	= Session::get('shop_user_name');
        Session::get('shop_name')	    == null || $this->shop_name 		= Session::get('shop_name');

        // 跳转登陆页面
        if($this->shop_id<=0){
            $this->redirect("login/index");
        }

        // 输出用户信息
        $this->assign('shop_info',$this->shop_info($this->shop_id));
    }


    /**
     * @throws
     * 商户信息
     */
    public function shop_info($shop_id)
    {
        return Db('shops')->where('shop_id',$shop_id)->find();
    }

}
